home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / share / pyshared / checkbox / plugin.py < prev    next >
Text File  |  2009-11-05  |  2KB  |  52 lines

  1. #
  2. # This file is part of Checkbox.
  3. #
  4. # Copyright 2008 Canonical Ltd.
  5. #
  6. # Checkbox is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # Checkbox is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with Checkbox.  If not, see <http://www.gnu.org/licenses/>.
  18. #
  19. import re
  20.  
  21. from checkbox.component import ComponentManager
  22.  
  23.  
  24. class PluginManager(ComponentManager):
  25.     """
  26.     Plugin manager which extends the component to support the concepts
  27.     of a reactor.
  28.     """
  29.     def __init__(self, config, reactor, registry):
  30.         super(PluginManager, self).__init__(config)
  31.         self.reactor = reactor
  32.         self.registry = registry
  33.  
  34.         # Load sections
  35.         self.sections = []
  36.         section_names = self._config.get_defaults().plugins
  37.         for section_name in re.split(r"\s+", section_names):
  38.             section = self.load_section(section_name)
  39.             self.sections.append(section)
  40.             for module in section.load_modules():
  41.                 module.register(self)
  42.  
  43.  
  44. class Plugin(object):
  45.     """
  46.     Plugin base class which should be inherited by each plugin
  47.     implementation. This class extends the component to automatically
  48.     call the run method if defined.
  49.     """
  50.     def register(self, manager):
  51.         self._manager = manager
  52.